home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Examples / Helpfile / _WordDocAddPicture.au3 < prev    next >
Text File  |  2007-09-08  |  762b  |  28 lines

  1. ; *******************************************************
  2. ; Example 1 - Create a word window with a new blank document,
  3. ;                then add some pictures to the document.
  4. ; *******************************************************
  5. ;
  6. #include <Word.au3>
  7.  
  8. $sPath = @WindowsDir & "\"
  9. $search = FileFindFirstFile($sPath & "*.bmp")
  10.  
  11. ; Check if the search was successful
  12. If $search = -1 Then
  13.     MsgBox(0, "Error", "No images found")
  14.     Exit
  15. EndIf
  16.  
  17. $oWordApp = _WordCreate ()
  18. $oDoc = _WordDocGetCollection ($oWordApp, 0)
  19.  
  20. While 1
  21.     $file = FileFindNextFile($search)
  22.     If @error Then ExitLoop
  23.     $oShape = _WordDocAddPicture ($oDoc, $sPath & $file, 0, 1)
  24.     If Not @error Then $oShape.Range.InsertAfter (@CRLF)
  25. WEnd
  26.  
  27. ; Close the search handle
  28. FileClose($search)